﻿using UnityEngine;

namespace HEFramework
{
    public static class LoginUISystem
    {
        [EntitySystem]
        public class LoginUIAwakeSystem : AwakeSystem<LoginUI>
        {
            protected override void Awake(LoginUI _self)
            {
                var uc = _self.GetSceneChild<UIComponent>();
                uc.PushUIAsync(eUIFlag.Login, _ => { _self.Run().Coroutine(); });
            }
        }


        [EntitySystem]
        public class LoginUIUpdateSystem : UpdateSystem<LoginUI>
        {
            protected override void Update(LoginUI _self)
            {
            }
        }


        [EntitySystem]
        public class LoginUIDestroySystem : DestroySystem<LoginUI>
        {
            protected override void Destroy(LoginUI _self)
            {
            }
        }


        public static async HETask Run(this LoginUI _self)
        {
            Entity scene = _self.GetScene();


            var rc = _self.GetSceneChild<ResourcesComponent>();

            // rc.Assets.LoadAssetAsync<AudioClip>("2d/audios", "sound",
            //     ResourceConfig.Extension.AUDIO_WAV, _ => { _self.GetSceneChild<AudioComponent>().AudioSource.Play(_); });


            await rc.UpdateAssetBundleFile();
            rc.LoadAssetBundleDependenciesSyn();


            await scene.GetChild<TimerComponent>().WaitAsync(3000);


            var dc = scene.GetChild<DataTableComponent>();
            dc.LoadLocalizationDic("Default");
            dc.LoadDataTable<DRMonster>();
            var mData = dc.GetDataTable<DRMonster>();

            //Log.Debug(mData.GetData(1001).Name);
            //Log.Debug("计时器结束");

            using ListObject<int> list = ListObject<int>.Create();

            //Main.New();
        }
    }
}